<?php
namespace Home\Controller;
use Think\Controller;

class AdminController extends CommonController
{
	public function index(){
		$this->display();
	}
	//展示顶端的html
	public function showTop(){
		$this->display('Index:top');
	}
	//展示左端的html
	public function showLeft(){
		session_start();

		$user = session('username');
		$date = date('Y-m-d',time());
		$this->assign('administrator', $user);
		$this->assign('date', $date);
		$this->display('Index:left');
	}
	//退出登录	
	public function exitLogin(){
		session_start();

		// 重置会话中的所有变量
		$_SESSION = array();

		// 注意：这样不但销毁了会话中的数据，还同时销毁了会话本身
		if (ini_get("session.use_cookies")) {
		    $params = session_get_cookie_params();
		    setcookie(session_name(), '', time() - 42000,
		        $params["path"], $params["domain"],
		        $params["secure"], $params["httponly"]
		    );
		}
		// 最后，销毁会话
		session_destroy();
		$this->redirect('Index/index');
	}
}